#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

class Solution{
    public:
    //使用额外数组
    void ans1(vector<int>& num, int k){
        int length = num.size();
        vector<int> temp (length);
        int new_k = k % length;
        for(int i = new_k; i != length; i++){
            temp[i] = num[i-new_k];
        }
        for(int i = 0; i != new_k; i++){
            temp[i] = num[length-new_k+i];
        }
        num = temp;  
    }

    void show(vector<int>& num){
        int length = num.size();
        cout << "[" << ends;
        for(int i = 0; i!= length-1; i++){
            cout << num[i] << "," << ends;
        }
        cout << num[length-1] << "]" << endl;
    }
};

void test1(){
    vector<int> num = {1, 2, 3, 4, 5, 6, 7};
    int k = 3;

    Solution s;
    s.ans1(num, k);
    s.show(num);
}

void test2(){
    vector<int> num = {-1, -100, 3, 99};
    int k = 2;

    Solution s;
    s.ans1(num, k);
    s.show(num);
}

void test3(){
    vector<int> num = {-1};
    int k = 2;

    Solution s;
    s.ans1(num, k);
    s.show(num);
}

void test4(){
    vector<int> num = {1, 2};
    int k = 3;

    Solution s;
    s.ans1(num, k);
    s.show(num);
}

int main(void){
    test1();
    test2();
    test3();
    test4();

    return 0;
}